package cn.vcjf.weapp.api.setting.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.ResponseBody;
import cn.vcjf.weapp.common.web.TableResult;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.vcjf.weapp.api.setting.entity.OrderOption;
import cn.vcjf.weapp.api.setting.service.OrderOptionService;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhengzihang
 * @since 2018-09-25
 */
@Controller
@RequestMapping("/setting/orderOption")
public class OrderOptionController {
	@Resource
	private OrderOptionService orderOptionService;

	@RequestMapping("/addOrderOption")
	@ResponseBody
	public TableResult addOrderOption(OrderOption orderOption) {
		orderOption.preInsert();
		boolean b = orderOptionService.insert(orderOption);
		return TableResult.Result(b);
	}

	@RequestMapping("/updateOrderOption")
	@ResponseBody
	public TableResult updateOrderOption(OrderOption orderOption) {
		orderOption.preUpdate();
		boolean b = orderOptionService.updateById(orderOption);
		return TableResult.Result(b);
	}

	@RequestMapping("/findOrderOptionOne")
	@ResponseBody
	public TableResult findOrderOptionOne(OrderOption orderOption) {

		EntityWrapper<OrderOption> wrapper = orderOption.getQueryWrapper();

		OrderOption result = orderOptionService.selectOne(wrapper);

		return TableResult.OKResult(result);
	}

	@RequestMapping("/findOrderOptionList")
	@ResponseBody
	public TableResult findOrderOptionList(OrderOption orderOption) {

		EntityWrapper<OrderOption> wrapper = orderOption.getQueryWrapper();

		Page<OrderOption> page = orderOption.getPageInfo();

		page = orderOptionService.selectPage(page, wrapper);

		return TableResult.OKResult(page);

	}

	@RequestMapping("/deleteOrderOption")
	@ResponseBody
	public TableResult deleteOrderOption(OrderOption orderOption) {
		orderOption.preUpdate();
		boolean b = orderOptionService.deleteById(orderOption.getId());
		return TableResult.Result(b);
	}

}
